package com.v3admin.config;

import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.BlockAttackInnerInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * Mybatis-plus配置
 *
 * @author Junpeng.Li
 * @date 2023-12-11 17:40
 */
@Configuration
@MapperScan("com.v3admin.**.mapper")
public class MybatisPlusConfig {

    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor() {
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
        // 防全表更新与删除插件, 文档地址: https://baomidou.com/pages/c571bc/#blockattackinnerinterceptor
        interceptor.addInnerInterceptor(new BlockAttackInnerInterceptor());
        // 分页插件, 如果配置多个插件, 切记分页最后添加, 文档地址: https://baomidou.com/pages/97710a/#paginationinnerinterceptor
        interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
        return interceptor;
    }

}
